package com.pro.control;

import com.pro.entity.JsonData;
import com.pro.entity.SystemInformation;
import com.pro.utils.InformationUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.management.MalformedObjectNameException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.net.UnknownHostException;

/**
 * auther 杨沛琪
 * createDate 2021/11/5
 */
@Controller
@RequestMapping("/Information")
public class InformationController {
    @RequestMapping("/getInformation")
    @ResponseBody
    public JsonData getInformation(HttpServletRequest request, HttpServletResponse response, HttpSession session, SystemInformation systemInformation) throws Exception {
        SystemInformation information = new SystemInformation();
        /*mysql版本*/
        information.setMysqlVersion(InformationUtils.getMysqlVerseion());
        /*服务器名称*/
        information.setServerName(InformationUtils.getServerName());
        /*服务器地址*/
        information.setServerAddress(InformationUtils.getserverAddress());
        /*操作系统*/
        information.setOperatingSystem(InformationUtils.getOperatingSystem());
        /*端口号*/
        information.setPortNumber(InformationUtils.getPortNumber(request));
        /*获取浏览器名称*/
        information.setIeName(InformationUtils.getIeName(request,response,session));
        /*获取浏览器版本*/
        information.setIeVersion(InformationUtils.getIeVersion(request,response,session));
        JsonData jsonData = new JsonData();
        jsonData.setData(information);
        return jsonData;
    }
}
